<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>test.il</title>
<meta name="generator" content="KF5::SyntaxHighlighting (Common Intermediate Language (CIL))"/>
</head><body style="color:#1f1c1b"><pre>
<span style="color:#898887;">// Test file for the Common Intermediate Language</span>

<span style="color:#898887;">/*</span>
<span style="color:#898887;">  multi line comment</span>
<span style="color:#898887;">*/</span>

<span style="color:#898887;">// examples from Wikipedia</span>
.<span style="color:#0057ae;">assembly</span> Hello {}
.<span style="color:#0057ae;">assembly</span> <span style="font-weight:bold;">extern</span> mscorlib {}
.<span style="font-weight:bold;">method</span> <span style="font-weight:bold;">static</span> <span style="color:#0057ae;">void</span> Main()
{
     .<span style="color:#0057ae;">entrypoint</span>
     .<span style="color:#0057ae;">maxstack</span> 1
     <span style="color:#644a9b;">ldstr</span> <span style="color:#bf0303;">&quot;Hello, world!&quot;</span>
     <span style="color:#644a9b;">call</span> <span style="color:#0057ae;">void</span> [mscorlib]System.Console::WriteLine(<span style="color:#0057ae;">string</span>)
     <span style="color:#644a9b;">ret</span>
}

.<span style="font-weight:bold;">method</span> <span style="font-weight:bold;">private</span> hidebysig <span style="font-weight:bold;">static</span> <span style="color:#0057ae;">void</span> Main(<span style="color:#0057ae;">string</span>[] args) <span style="font-weight:bold;">cil</span> <span style="font-weight:bold;">managed</span>
{
    .<span style="color:#0057ae;">entrypoint</span>
    .<span style="color:#0057ae;">maxstack</span>  2
    .<span style="color:#0057ae;">locals</span> init (<span style="color:#0057ae;">int32</span> V_0,
                  <span style="color:#0057ae;">int32</span> V_1)

              <span style="color:#644a9b;">ldc</span>.i4.2
              <span style="color:#644a9b;">stloc</span>.0
              <span style="color:#644a9b;">br</span>.s       IL_001f
    <span style="color:#006e28;">IL_0004:</span>  <span style="color:#644a9b;">ldc</span>.i4.2
              <span style="color:#644a9b;">stloc</span>.1
              <span style="color:#644a9b;">br</span>.s       IL_0011
    <span style="color:#006e28;">IL_0008:</span>  <span style="color:#644a9b;">ldloc</span>.0
              <span style="color:#644a9b;">ldloc</span>.1
              <span style="color:#644a9b;">rem</span>
              <span style="color:#644a9b;">brfalse</span>.s  IL_001b
              <span style="color:#644a9b;">ldloc</span>.1
              <span style="color:#644a9b;">ldc</span>.i4.1
              <span style="color:#644a9b;">add</span>
              <span style="color:#644a9b;">stloc</span>.1
    <span style="color:#006e28;">IL_0011:</span>  <span style="color:#644a9b;">ldloc</span>.1
              <span style="color:#644a9b;">ldloc</span>.0
              <span style="color:#644a9b;">blt</span>.s      IL_0008
              <span style="color:#644a9b;">ldloc</span>.0
              <span style="color:#644a9b;">call</span>       <span style="color:#0057ae;">void</span> [mscorlib]System.Console::WriteLine(<span style="color:#0057ae;">int32</span>)
    <span style="color:#006e28;">IL_001b:</span>  <span style="color:#644a9b;">ldloc</span>.0
              <span style="color:#644a9b;">ldc</span>.i4.1
              <span style="color:#644a9b;">add</span>
              <span style="color:#644a9b;">stloc</span>.0
    <span style="color:#006e28;">IL_001f:</span>  <span style="color:#644a9b;">ldloc</span>.0
              <span style="color:#644a9b;">ldc</span>.i4     0x3e8
              <span style="color:#644a9b;">blt</span>.s      IL_0004
              <span style="color:#644a9b;">ret</span>
}

.<span style="font-weight:bold;">method</span> <span style="color:#0057ae;">assembly</span> <span style="font-weight:bold;">static</span> <span style="color:#0057ae;">void</span> modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl)
        test_pointer_operations(<span style="color:#0057ae;">int32</span> param) <span style="font-weight:bold;">cil</span> <span style="font-weight:bold;">managed</span>
{
  .vtentry 1 : 1
  <span style="color:#898887;">// Code size       44 (0x2c)</span>
  .<span style="color:#0057ae;">maxstack</span>  2
  .<span style="color:#0057ae;">locals</span> ([0] <span style="color:#0057ae;">int32</span>* ptr,
           [1] valuetype A* V_1,
           [2] valuetype A* a,
           [3] <span style="color:#0057ae;">int32</span> k)
<span style="color:#898887;">// k = 0;</span>
  <span style="color:#006e28;">IL_0000:</span>  <span style="color:#644a9b;">ldc</span>.i4.0
  <span style="color:#006e28;">IL_0001:</span>  <span style="color:#644a9b;">stloc</span>.3
<span style="color:#898887;">// ptr = &amp;k;</span>
  <span style="color:#006e28;">IL_0002:</span>  <span style="color:#644a9b;">ldloca</span>.s   k <span style="color:#898887;">// load local's address instruction</span>
  <span style="color:#006e28;">IL_0004:</span>  <span style="color:#644a9b;">stloc</span>.0
<span style="color:#898887;">// *ptr = 1;</span>
  <span style="color:#006e28;">IL_0005:</span>  <span style="color:#644a9b;">ldloc</span>.0
  <span style="color:#006e28;">IL_0006:</span>  <span style="color:#644a9b;">ldc</span>.i4.1
  <span style="color:#006e28;">IL_0007:</span>  <span style="color:#644a9b;">stind</span>.i4 <span style="color:#898887;">// indirection instruction</span>
<span style="color:#898887;">// ptr = &amp;param</span>
  <span style="color:#006e28;">IL_0008:</span>  <span style="color:#644a9b;">ldarga</span>.s   param <span style="color:#898887;">// load parameter's address instruction</span>
  <span style="color:#006e28;">IL_000a:</span>  <span style="color:#644a9b;">stloc</span>.0
<span style="color:#898887;">// *ptr = 2</span>
  <span style="color:#006e28;">IL_000b:</span>  <span style="color:#644a9b;">ldloc</span>.0
  <span style="color:#006e28;">IL_000c:</span>  <span style="color:#644a9b;">ldc</span>.i4.2
  <span style="color:#006e28;">IL_000d:</span>  <span style="color:#644a9b;">stind</span>.i4
<span style="color:#898887;">// a = new A;</span>
  <span style="color:#006e28;">IL_000e:</span>  <span style="color:#644a9b;">ldloca</span>.s   a
  <span style="color:#006e28;">IL_0010:</span>  <span style="color:#644a9b;">call</span>       valuetype A* modopt([mscorlib]System.Runtime.CompilerServices.CallConvThiscall) 'A.{ctor}'(valuetype A* modopt([mscorlib]System.Runtime.CompilerServices.IsConst) modopt([mscorlib]System.Runtime.CompilerServices.IsConst))
  <span style="color:#006e28;">IL_0015:</span>  <span style="color:#644a9b;">pop</span>
<span style="color:#898887;">// ptra = &amp;a;</span>
  <span style="color:#006e28;">IL_0016:</span>  <span style="color:#644a9b;">ldloca</span>.s   a
  <span style="color:#006e28;">IL_0018:</span>  <span style="color:#644a9b;">stloc</span>.1
<span style="color:#898887;">// ptra-&gt;meth();</span>
  <span style="color:#006e28;">IL_0019:</span>  <span style="color:#644a9b;">ldloc</span>.1
  <span style="color:#006e28;">IL_001a:</span>  <span style="color:#644a9b;">dup</span>
  <span style="color:#006e28;">IL_001b:</span>  <span style="color:#644a9b;">ldind</span>.i4 <span style="color:#898887;">// reading the VMT for virtual call</span>
  <span style="color:#006e28;">IL_001c:</span>  <span style="color:#644a9b;">ldind</span>.i4
  <span style="color:#006e28;">IL_001d:</span>  <span style="color:#644a9b;">calli</span>      unmanaged stdcall <span style="color:#0057ae;">void</span> modopt([mscorlib]System.Runtime.CompilerServices.CallConvStdcall)(native int)
  <span style="color:#006e28;">IL_0022:</span>  <span style="color:#644a9b;">ret</span>
} <span style="color:#898887;">// end of method 'Global Functions'::test_pointer_operations</span>
</pre></body></html>
